<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<c:set var="baseUrl" value="${pageContext.request.contextPath }"></c:set>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>订单列表</title>
<script type="text/javascript" src="${baseUrl }/js/jquery-3.3.1.js"></script>
<link type="text/css" rel="stylesheet" href="${baseUrl }/css/style.css" />

<script type="text/javascript">
function doDel(id) {
	var flag = confirm("确认删除？");
	if(flag){
		window.location="${baseUrl }/BillController/deleteBill?id="+id
	}
}
	$(function(){
		var payStatus = ${payStatus}
		$("#select option").each(function(){
			if($(this).val()==payStatus){
				$(this).attr("selected",true)
			}
		})
	})

</script>


</head>
<body>
	<div class="menu">
		<form method="post" action="${baseUrl }/BillController/getAllBill">
			商品名称：<input type="text" name="billName" class="input-text" value="${billName }"/>&nbsp;&nbsp;&nbsp;&nbsp;
			是否付款：<select name="payStatus" id="select">
				<option value="">请选择</option>
				<option value="1">已付款</option>
				<option value="0">未付款</option>
			</select>&nbsp;&nbsp;<input type="submit" name="submit"
				value="组合查询" class="button" />
		</form>
	</div>
	<div class="main">
		<div class="optitle clearfix">
		<c:if test="${user1.supers eq 1 }">
			<em><input type="button" name="button" value="添加数据"
				class="input-button" onclick="location.href='${baseUrl }/addBill.jsp'" /></em>
		</c:if>
			<div class="title">账单管理&gt;&gt;</div>
		</div>
		<div class="content">
			<table class="list">
				<tr>
					<td>序号</td>
					<td>账单编号</td>
					<td>商品名称</td>
					<td>商品数量</td>
					<td>交易金额</td>
					<td>是否付款</td>
					<td>供应商编号</td>
					<td>商品描述</td>
					<td>账单时间</td>
					<c:if test="${user1.supers eq 1 }">
					<td colspan="2">操作</td>
					</c:if>
				</tr>
			<c:forEach items="${list }" var="bill">
				<tr>
					<c:set value="${i+1 }" var="i"></c:set>
					<td>${i }</td>
					<td>${bill.id }</td>
					<td>${bill.name }</td>
					<td>${bill.counts }</td>
					<td>${bill.money }</td>
					<c:if test="${bill.ispay==0 }">
					<td>没有</td>
					</c:if>
					<c:if test="${bill.ispay==1 }">
					<td>是</td>
					</c:if>
					<td>${bill.providerId }</td>
					<td>${bill.desc }</td>
					<td>${bill.time }</td>
					<c:if test="${user1.supers eq 1 }">
					<td colspan="2"><a href="javascript:doDel(${bill.id })">删除</a>
					&nbsp;&nbsp;<a href="${baseUrl }/BillController/getBill?id=${bill.id }">更新</a>
					</td>
					</c:if>
				</tr>
			</c:forEach>
			</table>
		</div>
	</div>
	
	<c:url value="BillController/getAllBill" var="first">
		<c:param name="pageIndex" value="1"></c:param>
		<c:param name="billName" value="${billName }"></c:param>
		<c:param name="payStatus" value="${payStatus }"></c:param>
	</c:url>
	<c:url value="BillController/getAllBill" var="forward">
		<c:param name="pageIndex" value="${pageIndex-1 }"></c:param>
		<c:param name="billName" value="${billName }"></c:param>
		<c:param name="payStatus" value="${payStatus }"></c:param>
	</c:url>
	<c:url value="BillController/getAllBillr" var="next">
		<c:param name="pageIndex" value="${pageIndex+1 }"></c:param>
		<c:param name="billName" value="${billName }"></c:param>
		<c:param name="payStatus" value="${payStatus }"></c:param>
	</c:url>
	<c:url value="BillController/getAllBill" var="last">
		<c:param name="pageIndex" value="${totalPage }"></c:param>
		<c:param name="billName" value="${billName }"></c:param>
		<c:param name="payStatus" value="${payStatus }"></c:param>
	</c:url>
	<font size="4" color="blue">
		<a href="${baseUrl }/${first }">首页</a>
	<!-- 当前页码等于1时隐藏"上一页" -->
	<c:if test="${pageIndex > 1 }">
		<a href="${baseUrl }/${forward }">上一页</a>
	</c:if>
	<!-- 当前页码为总页码时，隐藏"下一页" -->
	<c:if test="${pageIndex < totalPage }">
		<a href="${baseUrl }/${next }">下一页</a>
	</c:if>
		<a href="${baseUrl }/${last }">尾页</a>
		&nbsp;
		总共有<font color="red">${totalCount }</font>条数据，共<font color="red">${totalPage }</font>页
	</font>
</body>
</html>
